package com.ziroom.zifamily.zfcensor.resources;


import com.ziroom.zifamily.bussiness.common.exception.BussinessException;
import com.ziroom.zifamily.bussiness.common.pojo.dto.ManualCensorDTO;
import com.ziroom.zifamily.bussiness.common.result.Result;
import com.ziroom.zifamily.zfcensor.logic.CensorLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/**
 * <p>审核内容相关Restful接口</p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author cuiyh9
 * @version 1.0
 * @Date Created in 2018年11月24日 16:09
 * @since 1.0
 */
@Slf4j
@RestController
@RequestMapping("censor")
@Api(value = "/审核", description = "审核")
public class CensorResource {

    @Autowired
    private CensorLogic censorLogic;

    /**
     *
     * @author cuiyuhui
     * @created
     * @param
     * @return
     */
    @PostMapping("/censorByManual")
    @ApiOperation(value = "人工审核", notes = "人工审核", response = String.class)
    public Result censorByManual(@RequestBody ManualCensorDTO manualCensorDto) {
        if (manualCensorDto == null
                || StringUtils.isEmpty(manualCensorDto.getCensorIds())
                || manualCensorDto.getCensorLevel() == null
                || StringUtils.isEmpty(manualCensorDto.getCensorCode())) {
            return Result.failParamNull();
        }
        boolean flag = censorLogic.censorByManual(manualCensorDto);
        if (flag) {
            log.info("[人工审核成功]");
            return Result.ok();
        } else {
            return Result.failSystemError();
        }

    }

    /**
     *
     * @author cuiyuhui
     * @created
     * @param
     * @return
     */
    @GetMapping(value = "notifyCensorResult")
    @ApiOperation(value = "回调结果", notes = "回调结果", response = String.class)
    public Result notifyCensorResult() throws Exception {
        if (true) {
            throw  new BussinessException("test");
        }
        return Result.ok();
    }
}
